package cn.com.jonpad.controller;

import cn.com.jonpad.api.vo.Result;
import cn.com.jonpad.entity.RcUser;
import cn.com.jonpad.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jon Chan
 * @date 2018/9/10 17:44
 */
@RestController
@RequestMapping("user")
public class UserController {
	@Autowired
	private UserService userService;

	@GetMapping("findByUsername/{username}")
	public Result findByUsername(@PathVariable("username") String username){
		RcUser user = userService.findByUsername(username);
		if (user == null){
			return Result.failure(100,"用户不存在");
		}
		return Result.ok().setData(user);
	}
}
